FROM python:3.11.1-slim

RUN apt update
RUN apt install -y git sed gcc
RUN git clone https://github.com/ankicommunity/anki-sync-server
WORKDIR anki-sync-server
RUN git checkout v2.4.0
RUN sed -i 's/orjson==3.7.5/orjson==3.8.5/' src/requirements.txt
RUN pip install -r src/requirements.txt
WORKDIR src
COPY ankisyncd.conf .
RUN mkdir /data
RUN useradd -u 1427 -Md /anki-sync-server/src anki
RUN chown anki:anki ../ -R
RUN chown anki:anki /data
USER anki
CMD ["python", "-m", "ankisyncd"]
